package com.soup.lab.tools.faker.source;

import org.junit.jupiter.api.Test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;

public class URLStreamSourceTestCase {

    @Test
    public void testFile() throws IOException {
        URLStreamSource URLStreamSource = new URLStreamSource("file:///D:\\soup\\lab\\tool-lab\\src\\test\\resources\\a.txt");
        InputStream inputStream = URLStreamSource.getAsInputStream();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, Charset.defaultCharset()));
        bufferedReader.lines().forEach(System.out::println);
    }

    @Test
    public void testHttpUrl() throws IOException {
        URLStreamSource URLStreamSource = new URLStreamSource("https://www.baidu.com/");
        InputStream inputStream = URLStreamSource.getAsInputStream();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, Charset.defaultCharset()));
        bufferedReader.lines().forEach(System.out::println);
    }

}
